<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.bundle.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>
<!-- 中间主体 -->
<div class="container" style="margin-top: 50px">
    <div class="row">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-md-5">
                        <h1 class="col-md-5">商品管理</h1>
                    </div>
                    <div class="col-md-7">
                        <button class="btn btn-default pull-right" style="margin-top: 20px"
                                onclick="location.href='${pageContext.request.contextPath}/product/addProduct'">
                            添加商品
                            <sapn class="glyphicon glyphicon-plus"/>
                        </button>
                    </div>
                </div>
            </div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>商品编号</th>
                    <th>商品名称</th>
                    <th>商品价格</th>
                    <th>商品种类</th>
                </tr>
                </thead>
                <tbody>

                <c:if test="${!empty products}">
                    <c:forEach items="${products}" var="product">
                        <tr>
                            <td>${product.pid}</td>
                            <td>${product.pname}</td>
                            <td>${product.price}</td>
                            <td>${product.categoryName}</td>
                            <td>
                                <button class="btn btn-default  btn-info"
                                onclick="location.href='${pageContext.request.contextPath}/product/updateProduct?pid=${product.pid}'">
                                    修改
                                </button>
                                <button class="btn btn-default btn-danger btn-primary"
                                        onclick="location.href='${pageContext.request.contextPath}/product/delete?pid=${product.pid}'">
                                    删除
                                </button>
                            </td>
                        </tr>
                    </c:forEach>
                </c:if>

                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
</html>